home *** CD-ROM | disk | FTP | other *** search
/ BCI NET / BCI NET Dec 94.iso / archives / programming / utilities / safemem2.lha / SafeMem.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-01-05  |  1.8 KB  |  57 lines

  1. #ifndef SAFEMEM_H
  2. #define SAFEMEM_H
  3.  
  4. #ifdef SAFEMEM
  5.  
  6. #include <exec/types.h>
  7. #include <exec/memory.h>
  8.  
  9. /*
  10.  * Compile in safe routines instead of standard library ones
  11.  */
  12. #define AllocMem(s,t)  safe_AllocMem((s),(t), __FILE__, __LINE__)
  13. #define AllocAbs(s,l)  safe_AllocAbs((s),(l), __FILE__, __LINE__)
  14. #define FreeMem(a,s)   safe_FreeMem((a),(s),  __FILE__, __LINE__)
  15. #define ShowMemList()  safe_ShowMemList(__FILE__, __LINE__)
  16. #define FreeMemList()  safe_FreeMemList(__FILE__, __LINE__)
  17.  
  18. #define malloc(s)      safe_malloc((s), __FILE__, __LINE__)
  19. #define free(a)        safe_free((a),   __FILE__, __LINE__)
  20. #define realloc(a,s)   safe_realloc((a),(s), __FILE__, __LINE__)
  21. #define calloc(e,s)    safe_calloc((e),(s),  __FILE__, __LINE__)  
  22.  
  23. void *safe_AllocMem(ULONG Size, ULONG MemType, char *File, ULONG Line),
  24.      *safe_AllocAbs(ULONG Size, void *Location, char *File, ULONG Line),
  25.       safe_FreeMem(void *Address, ULONG Size, char *File, ULONG Line);
  26.  
  27. ULONG safe_ShowMemList(char *File, ULONG Line),
  28.       safe_FreeMemList(char *File, ULONG Line);
  29.  
  30. void *safe_malloc(ULONG Size,  char *File, ULONG Line);
  31. void  safe_free(void *Address, char *File, ULONG Line);
  32. void *safe_realloc(void *Address, ULONG NewSize, char *File, ULONG Line);
  33. void *safe_calloc(ULONG Elements, ULONG ElementSize, char *File, ULONG Line);
  34.  
  35. /*
  36.  * When gbl_SafeMem == 0, the SafeMem routines merely call the real versions,
  37.  * without any of the SafeMem checking. This provides an easy way to disable
  38.  * SafeMem without recompiling your entire program.
  39.  */
  40. extern ULONG far gbl_SafeMem;
  41.  
  42. /*
  43.  * gbl_SafeMemOutput is the function that is called to print the messages.
  44.  * The default is a printf() to stdout.
  45.  */
  46. extern void (*gbl_SafeMemOutput)();
  47.  
  48. #else
  49. /*
  50.  * Define away our routines into nothing
  51.  */
  52. #define ShowMemList()
  53. #define FreeMemList()
  54.  
  55. #endif
  56. #endif
  57.